import { Crypto, Base64 } from "./crypto.js"
const util = {
  aliOssParams(aid, aky, host) {
    var aid = aid;//你自己的阿里云的accessid
    var aky = aky;//你自己的阿里云的accesskey
    var host = host;//你自己的阿里云域名
    var policyText = {
      "expiration": "2922-01-01T12:00:00.000Z",//上传的文件失效日期自己定义
      "conditions": [
        ["content-length-range", 0, 10485760000]//上传的内容大小，自己定义
      ]
    };
    var policy = Base64.encode(JSON.stringify(policyText));//生成的加密策略
    var bytes = Crypto.util.HMAC(Crypto.util.SHA1, policy, aky, { asBytes: true });
    var signature = Crypto.util.bytesToBase64(bytes);//生成的签名
    return {
      policy: policy,
      signature: signature,
      aid: aid,
      host: host
    }
  }
}

export { util }  